function tri = make_mesh(d)
tri = zeros(d^2,3);% have d^2 elements
tri_begin = 1;
node_begin = 1;
for i = 1:d
    % first the \triangle
    tri(tri_begin:2:tri_begin+2*i-2,1) = [node_begin:node_begin+i-1]; %  line(i,1:2:end)
    tri(tri_begin:2:tri_begin+2*i-2,2)= [node_begin+i:node_begin+i+i-1]; %  line(i+1,1:end-1)
    tri(tri_begin:2:tri_begin+2*i-2,3)= [node_begin+i+1:node_begin+i+i]; %  line(i+1,2:end)
    % then the \gradient
    tri(tri_begin+1:2:tri_begin+2*i-2,1) = [node_begin:node_begin+i-2]; %  line(i,1:end-1)
    tri(tri_begin+1:2:tri_begin+2*i-2,2)= [node_begin+1:node_begin+i-1]; %  line(i,2:end)
    tri(tri_begin+1:2:tri_begin+2*i-2,3)= [node_begin+i+1:node_begin+i+i-1]; %   line(i+1,2:end-1)
    %prepare for next line;
    tri_begin = tri_begin + 2*i-1;
    node_begin = node_begin + i;
end